<?php

namespace mpend\modules\cms\models;

/**
 * 资讯相关或推荐检索列表模型
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class ArticleRelevantSearch extends ArticleSearch {

    /**
     * 资讯检索列表
     */
    public function search() {
        $article = static::findOne($this->id);
        if (!$article) {
            return [];
        }
        $query = static::find()->active(static::STATUS_ACTIVE);
        $query->with(['category', 'albums', 'video', 'stats']);
        $query->andWhere([
            'and',
            ['channel_id' => $article->channel_id],
        ]);
        $query->addOrderBy('rand()');
        $query->limit(3);
        return $query->all();
    }

}
